import React, { Component } from 'react'

export default function (Son) {
  return class Common extends Component {
    // react调试工具默认读取组件的静态属性displayName的值作为组件名展示.但是如果没有displayName则找组件的静态属性name展示
    static displayName = 'With' + Son.name
    state = {
      username: '',
      password: '',
      repassword: '',
    }
    handle = (name) => (e) => {
      this.setState({
        [name]: e.target.value.trim(),
      })
    }
    render() {
      return <Son {...this.state} handle={this.handle} {...this.props}></Son>
    }
  }
}
